#pragma once

#include "Material.h"
#include "Texture2D.h"
#include "XVulkan.h"

class FrameBuffer : public XBufferObject
{
  public:
    VkFramebuffer mFBO;
    VkRenderPass mRenderPass;
    uint32_t mWidth;
    uint32_t mHeight;
    std::vector<Texture2D *> mAttachments;
    int mColorBufferCount;
    std::vector<VkClearValue> mClearValues;
    Texture2D *mDepthBuffer;
    int mDepthBufferIndex = 0;

  public:
    FrameBuffer();
    ~FrameBuffer();

    void SetSize(uint32_t width, uint32_t height);
    void AttachColorBuffer(VkFormat format = VK_FORMAT_R8G8B8A8_UNORM);
    void AttachDepthBuffer();
    void Finish();
    void SetClearColor(int index, float r, float g, float b, float a);
    void SetClearDepthStencil(float depth, uint32_t stencil);
    VkCommandBuffer BeginRendering(VkCommandBuffer commandBuffer = VK_NULL_HANDLE);
};